<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\modules\Order\models\OrderCustomer;
use app\modules\Order\models\OrderPrice;
use kartik\editable\Editable;

$this->title = $model->product->name . '  ' . $model->product->go_time;
// 获取订单对应的人员信息
//$customer = OrderCustomer::find()->where(['order_id'=>$model->id, 'status'=>1])->all();
$customer = $model->customer;

//  获取订单附加费
$price = OrderPrice::find()->where(['order_id'=>$model->id, 'status'=>1])->all();

?>
<!-- ?=  yii\web\View::registerJsFile("/js/jquery.artZoom.js",['depends' => 'app\assets\AppAsset']) ? -->
<style type="text/css">
	.order-view font {color:#9E9A9A;margin-right:10px;}
	.for div {height: 40px;}
	.overflow {
		width: 100px;/*指定宽度*/
		height: 40px;
		float:left;
		display: inline-block;
	    word-break:keep-all;/* 不换行 */
	    white-space:nowrap;/* 强制在同一行内显示所有文本，直到文本结束或者遭遇 br 对象。不换行 */
		overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
		//text-overflow:ellipsis;/* IE 专有属性，当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/
	}
	#w2-cont {width:125px;}
	.k-remark .kv-editable {max-width: 90%;text-align:left;}
	.k-remark .kv-editable button {max-width: 840px;text-align:left;}
</style>

<div class="order-view-disable row" style="margin-left:0px;margin-right:0px;">

    <h2 class="page-header"><small><?= Html::encode($this->title) ?></small>
        <p class="pull-right">

			<?php if(Yii::$app->user->can('is_admin')){ ?>
				<?= ($model->status < 10)? Html::a('退回已付款', ['/order/order/back-status', 'id' => $model->id], [
						'class' => 'btn btn-danger',
						'data' => [
							'confirm' => '确定退回订单状态为已付款吗?',
							'method' => 'post',
						],
					]) : ''   
				?>
			<?php } ?>
			<?= ($model->status < 10)? Html::a('取消订单', ['/order/order/unrecovery', 'id' => $model->id], [
					'class' => 'btn btn-warning',
					'data' => [
						'confirm' => '确定取消该订单吗?',
						'method' => 'post',
					],
				]) : '已取消'   
			?>
            <?= Html::a(Yii::t('app', 'Index'), ['index', 'product_id' => $model->product_id], ['class' => 'btn btn-success']) ?>
        </p>
    </h2>

	<div class="col-md-10 col-md-offset-1 panel panel-body">
    <div class="col-md-3 for"  style="padding:10px 0px;">
        <div><font>舱房金额 :</font> <?= $model->total_sale?></div>
        <div>
			<font><?= ($model->check == 1 && $model->sale_price>0) ? '<i class="text-danger fa fa-check-circle"></i>' : '' ?>优惠额度:</font>&nbsp;<?= $model->sale_price ?>

    		<?php echo Editable::widget([
    		    'name' => 'Order[price_desc]',
				'value' => $model->price_desc,
    		    'asPopover' => true,
    		    'header' => '优惠说明',
				'displayValue' => '<i class="fa fa-tags"></i>',
				'inputType' => Editable::INPUT_TEXTAREA,
    		    'size'=>'md',
    		    'formOptions' => ['action'=>'/order/order/edit-ajax?Order[id]='.$model->id,'method'=>'get'],
    		    'options' => ['class'=>'form-control', 'placeholder'=>'请输入优惠说明'],
    		]);?>
		</div>
        <div><font>附加费 :</font> <span><?= $model->priceSum?></span></div>
        <div>
			<font>总金额 :</font> <span id="price"><?= $model->price?></span> &nbsp; 
			<a class="fa fa-th-list" data-toggle="modal" data-target=".customer-modal"  href="/order/order/price-detail?id=<?= $model->id ?>" ></a> 
		</div>
    </div>

    <div class="col-md-3 for"  style="padding:10px 0px;">
        <div><font>订单号 :</font> <?= $model->code ?></div>
        <div><font>来  源 :</font> <?= Yii::$app->params['order_source'][$model->source] ?></div>
        <div><font>销  售 :</font> <?= isset($model->member->profile->name) ? $model->member->profile->name : '(未设置)' ?></div>
		<div>
			<font>实  收 :</font> <?= Yii::$app->formatter->asCurrency($model->financeSuccess) ?>
			<a class="fa fa-th-list" data-toggle="modal" data-target=".customer-modal"  href="/finance/finance/order-detail?order_id=<?= $model->id ?>" ></a>
		</div>
    </div>


    <div class="col-md-3  for" style="padding:10px 0px 0px 0px;" >
        <div><font>联系人 :</font> 
    		<?= $model->username ?>
		</div>

        <div><font>联系电话 :</font> 
    		<?=  $model->phone ?>
		</div>
        <div><font>公司名称 :</font> 
    		<?=  $model->company?>
		</div>

    </div>

    <div class="col-md-3 for" style="padding:10px 0px;">
        <div><font>创建时间 :</font> <?= Yii::$app->formatter->asDate($model->created_at)?></div>
        <div><font>更新时间 :</font><?= Yii::$app->formatter->asRelativeTime($model->updated_at)?></div>
        <div><font>状  态 :</font> 
    		<b><?= Yii::$app->params['order_status'][$model->status]; ?></b>
		</div>
    </div>

   	<div class="col-md-11 k-remark" style="padding:0px 0px 15px 0; text-align:left;">
		<font>备 注 : </font>
    		<?= $model->remark ?>
	</div>
	</div>
	

	<?php if($price){ ?>
	<div class="col-md-10 col-md-offset-1">
		<h4 class="page-header" style="margin-top:5px;"><small>附加费列表</small></h4>
		<div class="row">
			<?php foreach($price as $val){ ?>
				<div style="height:40px;">
					<div class="col-md-4"><?= $val->typeObj->name ?></div>
					<div class="col-md-2">单价: <?= $val->price ?></div>
					<div class="col-md-2">人数: <?= $val->num ?> &nbsp; 人</div>
					<div class="col-md-2">总价: <?= $val->total_price ?> </div>
				</div>
			<?php } ?>
		</div>
	</div>
	<?php } ?>


    <br>

    <!-- 舱房信息分配 -->
    <?php echo $this->render('disable_room', ['model' => $model, 'customers'=>$customer]); ?>
</div>
